package com.xujie.property_warranty_system.enums;

import lombok.Getter;

/**
 * 维护类型枚举
 */
@Getter
public enum MaintenanceType {
    
    REGULAR(1, "定期维护"),
    REPAIR(2, "故障维修");
    
    private final Integer code;
    private final String description;
    
    MaintenanceType(Integer code, String description) {
        this.code = code;
        this.description = description;
    }
    
    /**
     * 根据类型码获取枚举
     */
    public static MaintenanceType fromCode(Integer code) {
        for (MaintenanceType type : MaintenanceType.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return REGULAR; // 默认返回定期维护
    }
}
